<?php
//NÃ£o mostra as mensagens de alerta
$display_success = $display_error = "style='display: none'";

if($has_alert != FALSE){

    if($msg_type == "success")
        $display_success = ''; //mostrar mensagem de sucesso
    else
        $display_error = ''; // mostrar mensagem de erro
}



?>
<script type="text/javascript" src="assets/js/publicar/aviso.js" charset="utf-8"></script>
<div class="container">	
	<h3 class="text-info">Avisos</h3>
	
		<div class="alert alert-error fade in" <?php echo $display_error;?>>
				<button type="button" class="close" data-dismiss="alert"><i class="icon-remove"></i> </button>
				<strong>Alerta</strong>
				<p><?php echo $alert_msg;?></p>
		</div>
	
		<div class="alert alert-success fade in" <?php echo $display_success;?> >
			<button type="button" class="close" data-dismiss="alert"><i class="icon-remove"></i> </button>
			<strong>Alerta</strong>
			<p><?php echo $alert_msg;?></p>
		</div>
	
		<div class="span3">
			<h4 class="muted">Categorias</h4>
			<p><a href="#nova_categoria_modal" data-toggle="modal"><span class="label label-info"><i class="icon-white icon-plus"></i> Nova categoria</a></span></p>
			<ul class="nav nav-tabs nav-stacked">
	  			<?php foreach($categorias as $categoria){ ?>
                    <li name="<?php echo $categoria->categoria_nome ?>" onclick="get_aviso_por_categoria(this,'<?php echo $categoria->categoria_id?>');">
                        <a><?php echo $categoria->categoria_nome ?> <i class="icon-chevron-right pull-right"></i></a>
                    </li>
                <?php } ?>
			</ul>
		</div>
		<div class="span7">
				<h4 class="muted" id="titulo_categoria">Titulo da categoria</h4>
				
				<input type="hidden" id="titulo-categoria"/>
				<p>
				    <a href="#novo_aviso_modal" data-toggle="modal"><span class="label label-info"><i class="icon-white icon-plus"></i> Novo aviso</span></a>
				    <a href="#editar_categoria_modal" data-toggle="modal"><span class="label label-info"><i class="icon-white icon-refresh"></i> Editar categoria</span></a>
				    <a href="#excluir_categoria_modal" data-toggle="modal"><span class="label label-info"><i class="icon-white icon-remove" id="icon-remove" value="0"></i> Excluir categoria</span></a>
			    </p>
					
		</div>
		<div id="content-avisos">
		    
		</div>
		<!-- MODAL DE NOVA CATEGORIA-->
			
		<div class="modal fade" id="nova_categoria_modal" style="display: none">
		  <div class="modal-dialog">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
		        <h3 class="modal-title muted">Cadastrar categoria</h3>
		      </div>
		      <div class="modal-body">
		      	<span class="text-info">Preencha todos os dados marcados com <span class="text-error">*</span></span>
		        <form method="post" action="index.php/publish/avisos/inserir_categoria">
    				<label>
				     <span class="text-error">*</span>
			         <input type="text" name="nome" id="nome" required="required" class="span4"  placeholder="Nome da categoria"/>
		            </label>
    				<hr>
    				<label>
				        <button type="submit" class="btn btn-primary">Cadastrar</button> 
				        <button type="reset" class="btn btn-danger">Cancelar</button>
				    </label>
				</form>
			
		      </div>
		      <div class="modal-footer">
		      </div>
		    </div><!-- /.modal-content -->
		  </div><!-- /.modal-dialog -->
		</div><!-- /.modal -->
		
		<!-- MODAL DE NOVO AVISO-->
			
		<div class="modal fade" id="novo_aviso_modal" style="display: none">
		  <div class="modal-dialog">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
		        <h3 class="modal-title muted">Novo aviso</h3>
		      </div>
		      <div class="modal-body">
		      	<span class="text-info">Preencha todos os dados marcados com <span class="text-error">*</span></span>
		        <form method="post" action="index.php/publish/avisos/publicar_aviso">
						<label> <span class="text-error">*</span> <input type="text" name="titulo" id="titulo" required="required" class="span4"  placeholder="Titulo do aviso"/> </label>
						<label>
							<span class="text-error">*</span>Categoria:
							<select required name="categoria" id="categoria">
                                <option value=""> Selecione uma categoria</option>
                                <?php foreach($categorias as $categoria){?>
                                 <option value="<?php echo $categoria->categoria_id ?>"><?php echo $categoria->categoria_nome ?></option>
                                <?php    
                                }
                                ?>
		                     </select>
						</label>
						
						<label>
                            <span class="text-error">*</span>Prioridade:
                            <select required name="prioridade" id="prioridade">
                                <option value="1">Normal</option>
                                <option value="2">Media</option>
                                <option value="3">Alta</option>
                             </select>
                        </label>
						
						<label><span class="text-error">*</span> <textarea name="conteudo" id="conteudo_aviso" required="required" class="span4" placeholder="Conteudo do aviso"></textarea></label>
						<hr>
						<label><button type="submit" class="btn btn-primary">Cadastrar</button> <button type="reset" class="btn btn-danger">Cancelar</button>  </label>
						
				</form>
			
		      </div>
		      <div class="modal-footer">
		      </div>
		    </div><!-- /.modal-content -->
		  </div><!-- /.modal-dialog -->
		</div><!-- /.modal -->
		
		<!-- MODAL DE EDIÇÃO DA CATEGORIA-->
			
		<div class="modal fade" id="editar_categoria_modal" style="display: none">
		  <div class="modal-dialog">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
		        <h3 class="modal-title muted">Editar categoria</h3>
		      </div>
		      <div class="modal-body">
		      	<span class="text-info">Preencha todos os dados marcados com <span class="text-error">*</span></span>
		        <form method="post" action="index.php/publish/avisos/editar_categoria">
						<label> 
						    <span class="text-error">*</span> 
						    <input type="text" name="categoria_nome" id="editar_nome_categoria" required="required" class="span4" placeholder="Nome da categoria"/>
						    <input type="hidden" name="categoria_id" id="editar_id_categoria" value="0"/> 
					    </label>
						
						<hr>
						<label><button type="submit" class="btn btn-primary">Editar</button> <button type="reset" class="btn btn-danger">Cancelar</button>  </label>
						
				</form>
			
		      </div>
		      <div class="modal-footer">
		      </div>
		    </div><!-- /.modal-content -->
		  </div><!-- /.modal-dialog -->
		</div><!-- /.modal -->
		
		
		
		<!-- MODAL DE EXCLUSÃO DA CATEGORIA-->
			
		<div class="modal fade" id="excluir_categoria_modal" style="display: none">
		  <div class="modal-dialog">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
		        <h3 class="modal-title muted">Exluir categoria</h3>
		      </div>
		      <div class="modal-body">
    	      	  <span id="modal-text">Deseja mesmo exluir a categoria Categoria?</span>
        		  <form method="post" action="index.php/publish/avisos/excluir_categoria">
        		      <input type="hidden" name="categoria" id="excluir-categoria"/>
    				<hr>
    				<label><button type="submit" class="btn btn-success" id="confirma-excluir">Confirma</button>
    			    <button class="btn btn-danger" onclick="fechar_modal('excluir_categoria_modal')">Cancelar</button>  </label>
        		 </form>
			
		      </div>
		      <div class="modal-footer">
		      </div>
		    </div><!-- /.modal-content -->
		  </div><!-- /.modal-dialog -->
		</div><!-- /.modal -->
		
		<!-- MODAL DE EXCLUSÃO DE AVISO-->
		<div class="modal fade" id="excluir_aviso_modal" style="display: none">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h3 class="modal-title muted">Exluir Aviso</h3>
              </div>
              <div class="modal-body">
                  <span id="modal-text">Deseja mesmo exluir o aviso?</span>
                  <form method="post" action="index.php/publish/avisos/excluir_aviso">
                      <input type="hidden" name="aviso" id="excluir-aviso"/>
                    <hr>
                    <label><button type="submit" class="btn btn-success" id="confirma-excluir">Confirma</button>
                    <button class="btn btn-danger" onclick="fechar_modal('excluir_categoria_modal')">Cancelar</button>  </label>
                 </form>
            
              </div>
              <div class="modal-footer">
              </div>
            </div><!-- /.modal-content -->
          </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->
		
</div>